package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.FriendDynamics;
import cn.wolfcode.trip.base.domain.User;
import cn.wolfcode.trip.base.mapper.FriendDynamicsMapper;
import cn.wolfcode.trip.base.query.FriendQuery;
import cn.wolfcode.trip.base.service.IFriendDynamicsService;
import cn.wolfcode.trip.base.util.UserContext;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class FriendDynamicsServiceImpl implements IFriendDynamicsService {
    @Autowired
    private FriendDynamicsMapper friendDynamicsMapper;
    @Override
    public PageInfo query(FriendQuery qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize(),qo.getOrderBy());
        List<FriendDynamics> list = friendDynamicsMapper.selectForList(qo);
        return new PageInfo(list);
    }

    @Override
    public void addFriendDynamics(FriendDynamics fd) {
        User currentUser = UserContext.getCurrentUser();
        fd.setUser(currentUser);
        friendDynamicsMapper.insert(fd);
    }
}
